﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultLedger.aspx.cs" Inherits="Main_Company_DefaultLedger" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Default Ledger</title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <link href="../../Styles/Tab/StyleSheet.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    
   	   	 .ajax__tab_technorati-theme .ajax__tab_hover .ajax__tab_outer
        {
            cursor: pointer;
        }
        .ajax__tab_technorati-theme .ajax__tab_hover .ajax__tab_inner
        {
            cursor: pointer;
        }
        .ajax__tab_technorati-theme .ajax__tab_hover .ajax__tab_tab
        {
            cursor: pointer;
        }

</style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scriptmanager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <asp:HiddenField ID="hidActiveIndex" runat="server" Value="0" />
    <div style="width: 80%; margin-left: 10%; margin-right: 10%;">
        <center>
            <asp:Label ID="lblMsg" runat="server" ForeColor="#f29e08" Font-Bold="true"></asp:Label>
        </center>
    </div>
    <ajaxToolkit:TabContainer id="Tabs" runat="server" cssclass="ajax__tab_technorati-theme"
        onactivetabchanged="Tabs_ActiveTabChanged" autopostback="true">
    <ajaxToolkit:TabPanel id="tabpanel1" runat="server" HeaderText="CST/VAT" >
        <ContentTemplate>
            <asp:Panel ID="pnlCheckbox" runat="server">
                <table width="100%" cellpadding="10px" class="tablecontent">
                    <tr>
                        <td align="center" style="border-left: solid 1px #818181;">
                            <asp:CheckBox ID="ChkSales" runat="server" Text="Sales" AutoPostBack="true" OnCheckedChanged="ChkSales_CheckedChanged" />
                        </td>
                        <td align="center">
                            <asp:CheckBox ID="ChkPurchase" runat="server" Text="Purchase" AutoPostBack="true"
                                OnCheckedChanged="ChkPurchase_CheckedChanged" />
                        </td>
                        <td align="center" style="border-right: solid 1px #818181;">
                            <asp:CheckBox ID="ChkTax" runat="server" Text="Tax" AutoPostBack="true" OnCheckedChanged="ChkTax_CheckedChanged" />
                        </td>
                        <td align="right">
                            <asp:CheckBox ID="ChkCST" runat="server" Text="CST" AutoPostBack="true" OnCheckedChanged="ChkCST_CheckedChanged" />
                        </td>
                        <td align="center" style="border-right: solid 1px #818181;">
                            <asp:CheckBox ID="ChkVAT" runat="server" Text="VAT" AutoPostBack="true" OnCheckedChanged="ChkVAT_CheckedChanged" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <br />
            <asp:GridView ID="grdDefaultLedger1" runat="server" CssClass="gridview" Width="100%"
                AutoGenerateColumns="false" AlternatingRowStyle-CssClass="gridview_alternate">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            Select</HeaderTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:CheckBox ID="ChkSelect" runat="server" onclick="CheckSelectAll()" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            Ledger Name</HeaderTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:Label ID="lblLedgerName" runat="server" Text='<%#Eval("LedgerName") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="Tax Type" DataField="TAXType" />
                    <asp:TemplateField >
                    <HeaderTemplate>Accounting Group</HeaderTemplate>
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemTemplate>
                    <asp:Label ID="lblAccountGroup" runat="server" Text='<%#Eval("ACCOUNTING GROUP") %>'></asp:Label>
                    <asp:HiddenField ID="hidMainClassID" runat="server" Value='<%#Eval("MAINCLASSID")%>' />
                    <asp:HiddenField ID="hidSubClassID" runat="server" Value='<%#Eval("SUBCLASSID")%>' />
                    <asp:HiddenField ID="hidGid" runat="server" Value='<%#Eval("GID")%>' />
                    <asp:HiddenField ID="hidTaxTypeID" runat="server" Value='<%#Eval("TAXTYPEID")%>' />
                    <asp:HiddenField ID="hidParentTaxTypeId" runat="server" Value='<%#Eval("PARENTTAXTYPEID")%>' />
                    </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                <center><span style="color:Red; font-weight:bold;">Record Not Found !</span></center>
                </EmptyDataTemplate>
            </asp:GridView>
         </ContentTemplate>
    </ajaxToolkit:TabPanel>
    <ajaxToolkit:TabPanel id="tabpanel2" runat="server" HeaderText="Others">
        <ContentTemplate>
            <asp:GridView ID="grdDefaultLedger2" runat="server" CssClass="gridview" Width="100%"
                AutoGenerateColumns="false" AlternatingRowStyle-CssClass="gridview_alternate">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            Select</HeaderTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:CheckBox ID="ChkSelect2" runat="server" onclick="CheckSelectAll()" />
                        </ItemTemplate>
                    </asp:TemplateField>
                     <asp:TemplateField>
                        <HeaderTemplate>
                            Ledger Name</HeaderTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:Label ID="lblLedgerName2" runat="server" Text='<%#Eval("LedgerName") %>'></asp:Label>
                            <asp:HiddenField ID="hidGid2" runat="server" Value='<%#Eval("GID")%>' />
                            <asp:HiddenField ID="hidParentTaxTypeId2" runat="server" Value='<%#Eval("PARENTTAXTYPEID")%>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="Tax Type" DataField="TAXType" />
                    <asp:BoundField HeaderText="Accounting Group" DataField="Accounting Group" />
                </Columns>
                   <EmptyDataTemplate>
                <center><span style="color:Red; font-weight:bold; vertical-align:middle;">Record Not Found !</span></center>
                </EmptyDataTemplate>
            </asp:GridView>
        </ContentTemplate>
    </ajaxToolkit:TabPanel>
 </ajaxtoolkit:tabcontainer>
    <div style="width: 86%; margin-left: 7%; margin-right: 7%;">
        <table width="100%" style="padding-top: 10px;">
            <tr>
                <td colspan="3" align="left" style="padding-top: 10px;">
                    <asp:CheckBox ID="ChkSelectAll" runat="server" Text="Select All" onclick="SelectAll(this.id);" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:CheckBox ID="ChkLink" runat="server" AutoPostBack="true" Text="Link Created Ledger To tax Classification" />
                </td>
                <td align="right">
                    <b>Total :</b>&nbsp;<asp:Label ID="lblTotal" runat="server"></asp:Label>
                </td>
                <td align="right">
                    <asp:Button ID="btnCreate" runat="server" Text="Create" CssClass="button" OnClick="btnCreate_Click" />
                    &nbsp;&nbsp;<asp:Button ID="btnClose" runat="server" Text="Close" CssClass="button" />
                </td>
            </tr>
        </table>
    </div>
    <br />
    <br />
    </form>
</body>

<script type="text/javascript" language="javascript">

    function SelectAll(id) {
        var index = document.getElementById("hidActiveIndex").value;
        if (index == "1") {
            //var cdi =document.getElementById('<%=this.Tabs.ClientID%>');

            //get reference of GridView control
            var grid = document.getElementById("<%= grdDefaultLedger2.ClientID %>");

            //variable to contain the cell of the grid
            var cell;
            if (grid.rows.length > 0) {
                //loop starts from 1. rows[0] points to the header.
                for (i = 1; i < grid.rows.length; i++) {
                    //get the reference of first column
                    cell = grid.rows[i].cells[0];

                    //loop according to the number of childNodes in the cell
                    for (j = 0; j < cell.childNodes.length; j++) {
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type == "checkbox") {
                            //assign the status of the Select All checkbox to the cell checkbox within the grid
                            cell.childNodes[j].checked = document.getElementById(id).checked;
                        }
                    }
                }
            }
        }
        else {
            //var cdi =document.getElementById('<%=this.Tabs.ClientID%>');

            //get reference of GridView control
            var grid = document.getElementById("<%= grdDefaultLedger1.ClientID %>");

            //variable to contain the cell of the grid
            var cell;
            if (grid.rows.length > 0) {
                //loop starts from 1. rows[0] points to the header.
                for (i = 1; i < grid.rows.length; i++) {
                    //get the reference of first column
                    cell = grid.rows[i].cells[0];

                    //loop according to the number of childNodes in the cell
                    for (j = 0; j < cell.childNodes.length; j++) {
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type == "checkbox") {
                            //assign the status of the Select All checkbox to the cell checkbox within the grid
                            cell.childNodes[j].checked = document.getElementById(id).checked;
                        }
                    }
                }
            }
        }
    }

    function CheckSelectAll() {

        var countchecked = 0;
        var index = document.getElementById("hidActiveIndex").value;
        if (index == "1") {
            //get reference of GridView control
            var grid = document.getElementById("<%= grdDefaultLedger2.ClientID %>");
            //variable to contain the cell of the grid
            var cell;
            if (grid.rows.length > 0) {
                //loop starts from 1. rows[0] points to the header.
                for (i = 1; i < grid.rows.length; i++) {
                    //get the reference of first column
                    cell = grid.rows[i].cells[0];
                    //loop according to the number of childNodes in the cell
                    for (j = 0; j < cell.childNodes.length; j++) {
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type == "checkbox") {
                            //assign the status of the Select All checkbox to the cell checkbox within the grid
                            if (cell.childNodes[j].checked == true) {
                                countchecked = countchecked + 1;
                            }
                        }
                    }
                }

                if (countchecked + 1 == grid.rows.length) {
                    document.getElementById("ChkSelectAll").checked = true;
                }
                else {
                    document.getElementById("ChkSelectAll").checked = false;
                }
            }
        }
        else {
            //var cdi =document.getElementById('<%=this.Tabs.ClientID%>');

            //get reference of GridView control
            var grid = document.getElementById("<%= grdDefaultLedger1.ClientID %>");

            //variable to contain the cell of the grid
            var cell;
            if (grid.rows.length > 0) {
                //loop starts from 1. rows[0] points to the header.
                for (i = 1; i < grid.rows.length; i++) {
                    //get the reference of first column
                    cell = grid.rows[i].cells[0];

                    //loop according to the number of childNodes in the cell
                    for (j = 0; j < cell.childNodes.length; j++) {
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type == "checkbox") {
                            //assign the status of the Select All checkbox to the cell checkbox within the grid
                            if (cell.childNodes[j].checked == true) {
                                countchecked = countchecked + 1;
                            }
                        }
                    }
                }

                if (countchecked + 1 == grid.rows.length) {
                    document.getElementById("ChkSelectAll").checked = true;
                }
                else {
                    document.getElementById("ChkSelectAll").checked = false;
                }
            }
        }
    }
</script>

</html>
